package com.dr.springboot.starter.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

/**
 * Created by rui on 2018/7/25.
 */
@Slf4j
@Component
public class TestScheduled {

    private final static SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-DD hh:mm:ss");

    //    todo scheduled 设置周期性运行的任务，可以设置时间周期
    @Scheduled(initialDelay = 2000, fixedRate = 10000)
    public void task() {
        log.info("定时器周期运行：" + dateFormat.format(new Date()));
    }
}
